/*
 * @Author: 雷小天 
 * @Date: 2021-11-19 15:12:10 
 * @Last Modified by: 雷小天
 * @Last Modified time: 2021-12-14 14:18:50
 */

<template>
  <div class="fly-home fly-panel" style="background-image: url();">
  <img :src="user.head_img" :alt="user.nickname">
  <i class="iconfont icon-renzheng" title="Fly社区认证"></i>
  <h1>
    {{user.nickname}}
    <i class="iconfont icon-nan"></i>
    <!-- <i class="iconfont icon-nv"></i>  -->
    <i v-if="user.is_vip>0" class="layui-badge fly-badge-vip">VIP{{user.is_vip}}</i>
    <!--
    <span style="color:#c00;">（管理员）</span>
    <span style="color:#5FB878;">（社区之光）</span>
    <span>（该号已被封）</span>
    -->
  </h1>

  <p style="padding: 10px 0; color: #5FB878;">认证信息：layui 作者</p>

  <p class="fly-home-info">
    <i class="iconfont icon-kiss" title="飞吻"></i><span style="color: #FF7200;">{{user.reward}} 飞吻</span>
    <i class="iconfont icon-shijian"></i><span>2016-12-25 19:09:41 加入</span>  
    <i class="iconfont icon-chengshi"></i><span>来自杭州</span>
  </p>

  <p class="fly-home-sign">（人生仿若一场修行）</p>

  <div class="fly-sns" data-user="">
    <a href="javascript:;" class="layui-btn layui-btn-primary fly-imActive" data-type="addFriend">加为好友</a>
    <a href="javascript:;" class="layui-btn layui-btn-normal fly-imActive" data-type="chat">发起会话</a>
  </div>

</div>

<div class="layui-container">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md6 fly-home-jie">
      <div class="fly-panel">
        <h3 class="fly-panel-title">{{user.nickname}} 最近的提问</h3>
        <ul class="jie-row">
          <li v-for="(item) in postData.rows" :key="item.id">
            <span v-if="item.is_wonderful === 1" class="fly-jing">精</span>
            <a :href="'/post/'+item.id" class="jie-title">{{item.title}}</a>
            <i>{{item.create_date}}</i>
            <em class="layui-hide-xs">{{item.view_count}}阅/{{item.comment_count}}答</em>
          </li>
          <!-- <div class="fly-none" style="min-height: 50px; padding:30px 0; height:auto;"><i style="font-size:14px;">没有发表任何求解</i></div> -->
        </ul>
      </div>
    </div>

    <div class="layui-col-md6 fly-home-da">
      <div class="fly-panel">
        <h3 class="fly-panel-title">{{user.nickname}} 最近的回答</h3>
        <ul class="home-jieda">
          <li>
          <p>
          <span>1分钟前</span>
          在<a href="" target="_blank">tips能同时渲染多个吗?</a>中回答：
          </p>
          <div class="home-dacontent">
            尝试给layer.photos加上这个属性试试：
            <pre>
            full: true
            </pre>
            文档没有提及
          </div>
        </li>
        <li>
          <p>
          <span>5分钟前</span>
          在<a href="" target="_blank">在Fly社区用的是什么系统啊?</a>中回答：
          </p>
          <div class="home-dacontent">
            Fly社区采用的是NodeJS。分享出来的只是前端模版
          </div>
        </li>

          <!-- <div class="fly-none" style="min-height: 50px; padding:30px 0; height:auto;"><span>没有回答任何问题</span></div> -->
        </ul>
      </div>
    </div>
  </div>
</div>
</template>

<script>
import request from '@/utils/request'
import Cookies from 'js-cookie'
import { ElMessage } from 'element-plus'
import { mapState } from "vuex";
export default {
  components: {
  },
  data() {
    return {
      id: 0, //ID
      title: "", //标题
      address: "bbs.100txy.com", //地址
      user: {}, //用户信息
      postData: {}, //发布帖子
      comment: [], // 帖子评论列表
      isSign: false,
      signinfo: {
        days:0
      },
      signinHelp: false,
    };
  },
  mounted(){
    console.log(this.$route)
    console.log("user_id:",this.$route.params.id)
    this.getUserSign()
    this.getDetail(this.$route.params.id) //获取用户详情
  },
  setup(){
    console.log("setup start")
    myFn()
    function myFn(){
      console.log("aaa");
    }
    return {
      myFn
    }
  },
  computed: {
      ...mapState(["user"])
  },
  methods: {
    //获取用户详情
    getDetail(id) {
      const params = {
        params: {
        }
      }
      request.get('/micro-bbs/v1/user/'+id, params).then((res) => {
        const { code, data } = res
        console.log("data:",data)
        if (code === 200) {
          this.title = data.title
          this.user = data.user
          this.postData = data.postData
        }
      })
    },
    //获取用户签到
    getUserSign(){
      if(Cookies.get('app.token') != ""){
         const params = {
        params: {
        }
      }
      request.get('/micro-bbs/v2/members/signinfo', params).then((res) => {
        const { code, data } = res
        if (code === 200) {
          console.log("data:",data)
          // this.isSign = data.is_sign
          // this.signinfo = data.signInfo
          this.$store.commit('setSignInfo',data)
        }else{
          //未签到不处理
        }
      })
      }
    },
    signTop(){
      ElMessage({
        message: '暂未开通',
        type: 'warning',
        offset: 200
      })
    }
  }
}
</script>